# Maintainer: Jelle van der Waa <jelle@vdwaa.nl>

_pyname=frozenlist
pkgname=python-${_pyname}
pkgver=1.4.0
pkgrel=1
pkgdesc='FrozenList is a list-like structure which can be made immutable'
url='https://github.com/aio-libs/frozenlist'
arch=('loong64' 'x86_64')
license=('Apache')
depends=('python')
makedepends=('cython' 'python-build' 'python-installer' 'python-wheel' 'python-setuptools')
checkdepends=('python-pytest' 'python-pytest-cov' 'python-pytest-runner')
source=(${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha512sums=('937f7684df3879596903b5ce2d9a38590383a7c319e3079bbd8fdcbea169c692d9feabac0a7e0646d334ec517a86f7d943e0b0107fd925203de1cc8029b252ba')
b2sums=('ec33639c22448da84fda9eaa83a78737f20579061e0ae05699a361ac9a8646df0ebf5c31df69cd7c4ee1c1c7fc0e28d0f6050a1879c3d28bf83e2caf442eb2a3')

prepare() {
  cd "${_pyname}-${pkgver}"
  sed 's|.install-cython ||' -i Makefile
}

build() {
  cd "${_pyname}-${pkgver}"
  make cythonize
  python -m build --wheel --no-isolation
}

check() {
  cd "${_pyname}-${pkgver}"
  local _python_version=$(python -c 'import sys; print("".join(map(str, sys.version_info[:2])))')
  PYTHONPATH="$PWD/build/lib.linux-$CARCH-cpython-${_python_version}" pytest
}

package() {
  cd "${_pyname}-${pkgver}"
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 CHANGES.rst README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
}

# vim: ts=2 sw=2 et:
